package com.facefun.service.Impl;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Service;

import com.facefun.Enum.StateCode;
import com.facefun.domain.Pic;
import com.facefun.service.PicService;
import com.facefun.util.FileUploadUtil;

@Service
public class PicServiceImpl extends BaseService<Pic> implements PicService {

	@Override
	public StateCode removePic(Integer id, HttpServletRequest request) {
		try {
			Pic pic=selectByPrimaryKey(id);
			if(pic==null){
				return StateCode.NOTEXISIT;
			}
			FileUploadUtil.uploadDelete(pic.getPgImg(), request);
			deleteByKey(id);
		} catch (Exception e) {
			return StateCode.Error;
		}
			
		return StateCode.SUCCESS;
	}

}
